package com.xzh.wms.enums;


import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Optional;


public enum CategoryStatus {

    IN_STOCK(1,"下架"),
    OUT_STOCK(2,"上架"),
    DEFAULT(120,"删除");

    @Setter @Getter
    private int code;
    @Setter @Getter
    private String message;

    CategoryStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }
    public static CategoryStatus getByCode(int code){
        CategoryStatus[] status= CategoryStatus.values();
        Optional<CategoryStatus> first = Arrays.stream(status).filter(items->items.code == code).findFirst();
        return first.orElse(null);
    }
}
